﻿using System;
using System.Runtime.CompilerServices;
using UnityEngine;

public static class RendererExtension
{
    public static Material FindMaterial(this Renderer renderer, string name)
    {
        <FindMaterial>c__AnonStorey8D storeyd = new <FindMaterial>c__AnonStorey8D {
            name = name
        };
        return Array.Find<Material>(renderer.materials, new Predicate<Material>(storeyd.<>m__189));
    }

    public static Material FindMaterial(this Renderer[] renderers, string name)
    {
        foreach (Renderer renderer in renderers)
        {
            foreach (Material material in renderer.materials)
            {
                if (material.name.Replace(" (Instance)", string.Empty) == name)
                {
                    return material;
                }
            }
        }
        return null;
    }

    public static Material FindSharedMaterial(this Renderer renderer, string name)
    {
        <FindSharedMaterial>c__AnonStorey8E storeye = new <FindSharedMaterial>c__AnonStorey8E {
            name = name
        };
        return Array.Find<Material>(renderer.sharedMaterials, new Predicate<Material>(storeye.<>m__18A));
    }

    [CompilerGenerated]
    private sealed class <FindMaterial>c__AnonStorey8D
    {
        internal string name;

        internal bool <>m__189(Material x)
        {
            return (x.name.Replace(" (Instance)", string.Empty) == this.name);
        }
    }

    [CompilerGenerated]
    private sealed class <FindSharedMaterial>c__AnonStorey8E
    {
        internal string name;

        internal bool <>m__18A(Material x)
        {
            return (x.name == this.name);
        }
    }
}

